﻿<%@ Page Title="" Language="C#" MasterPageFile="~/CricketAdmin.master" AutoEventWireup="true"
    CodeFile="Toss.aspx.cs" Inherits="Toss" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%=btnSubmit.ClientID %>').hide();
        });
        function GetActiveMatch() {
            var matchId = $('#<%=drpMatch.ClientID %> option:selected').val();
            if (matchId != undefined && matchId != "0") {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",

                    data: "{'matchId': " + matchId + "}",
                    url: "Toss.aspx/GetActiveMatch",
                    dataType: "json",
                    async: false,
                    success: function (data) {
                        var results = data.d;
                        if (results != null) {
                            //html(results[i].KhadhiRate)<span id="spScore" style="font-weight: bold; font-size: x-large;">IND (10 - 101/2)</span>
                            //$("#spScore").html(results[0].TeamName + '' + '(' + results[0].Over + '' + ' - ' + results[0].Run + ')')
                            if (results[0].IsOn == true) {
                                $('#<%=btnSubmit.ClientID %>').show();
                            }

                            else {
                                $('#<%=btnSubmit.ClientID %>').hide();
                            }

                        }
                        else {
                            $('#<%=btnSubmit.ClientID %>').hide();
                        }
                    },
                    error: function (response) {
                        //alert('e');
                    }
                });

            }
        }

        window.setInterval(function () {
            GetActiveMatch();
        }, 2000);
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <div class="container-fluid">
        <h3 class="page-title">
            Toss Betting
        </h3>
        
        
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption">
                    Toss Betting</div>
                <div class="actions">
                    <span id="spScore" style="font-weight: bold; font-size: x-large;"></span>
                </div>
            </div>
            <div class="portlet-body form">
                <asp:UpdatePanel ID="updPanelBetting" runat="server">
                    <ContentTemplate>
                        <div class="alert alert-danger" id="layerError" runat="server" style="display: none;">
                        </div>
                        <div class="alert alert-success" id="layerSuccess" runat="server" style="display: none;">
                        </div>
                        <div class="form-horizontal form-view">
                            <div class="row-fluid">
                                <div class="span12">
                                    <div class="control-group">
                                        <label class="control-label">
                                            Select Match<span class="required">*</span></label>
                                        <div class="controls">
                                            <asp:DropDownList ID="drpMatch" runat="server" OnSelectedIndexChanged="drpMatch_SelectedIndexChanged"
                                                AutoPostBack="true">
                                            </asp:DropDownList>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please enter match"
                                                InitialValue="0" ValidationGroup="ClientToss" CssClass="required" ControlToValidate="drpMatch"
                                                Display="Dynamic"></asp:RequiredFieldValidator>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="control-group">
                                        <label class="control-label">
                                            Select Team<span class="required">*</span></label>
                                        <div class="controls">
                                            <asp:DropDownList ID="drpTeam" runat="server">
                                            </asp:DropDownList>
                                            <asp:RequiredFieldValidator ID="rfvTeam" runat="server" ErrorMessage="Please selecct team"
                                                InitialValue="0" ValidationGroup="ClientToss" CssClass="required" ControlToValidate="drpTeam"
                                                Display="Dynamic"></asp:RequiredFieldValidator>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row-fluid" id="divBettingTeamA" runat="server">
                                <div class="span12">
                                    <div class="control-group">
                                        <div class="controls">
                                            <div class="input-prepend" id="divOverTeamA" runat="server">
                                                <span class="add-on" id="lblSessionOverTeamA">Chips</span>
                                            </div>
                                            <div class="input-prepend">
                                                <asp:TextBox ID="txtAmount" type="number" CssClass="m-wrap span8" runat="server"></asp:TextBox>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row-fluid">
                                <div class="span6">
                                    <div class="control-group" id="errorLagadi">
                                        <label class="control-label">
                                        </label>
                                        <div class="controls">
                                            <asp:Button ID="btnSubmit" runat="server" ValidationGroup="ClientToss" Text="Submit"
                                                CssClass="btn blue btnSubmit" onclick="btnSubmit_Click" />
                                        </div>
                                        <%--OnClick="btnSubmit_Click"--%>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
</asp:Content>
